<template>
    <div>
        <bi-form-item label="选择方式" >
            <bi-select v-model="form.selectType" :clear="false"  >
                <bi-select-option value="goods" label="商品"></bi-select-option>
                <bi-select-option value="category" label="分类" ></bi-select-option>
                
                <bi-select-option value="brand" label="品牌"></bi-select-option>
                <bi-select-option value="tag" label="标签" ></bi-select-option>
                <bi-select-option value="like" label="用户喜好"></bi-select-option>
                <bi-select-option value="spec" label="规格"></bi-select-option>
                <bi-select-option value="variable" label="变量"></bi-select-option>
            </bi-select>
        </bi-form-item>
        
        <bi-form-item label="选择分类"   v-if="form.selectType=='category'">
            <cate v-model="form.cateId"  ></cate>
        </bi-form-item>

        <bi-form-item label="选择商品"  v-if="form.selectType=='goods'">
            <goods v-model="form.goodsIds" ></goods>
        </bi-form-item>

        <!--
        <bi-form-item label="选择品牌"  v-if="form.selectType=='brand'">
            <brand v-model="form.brandId" ></brand>
        </bi-form-item>

        
        -->
        <bi-form-item label="选择标签"  v-if="form.selectType=='tag'">
            <tag v-model="form.tag" ></tag>
        </bi-form-item>
        <bi-form-item label="选择规格"  v-if="form.selectType=='spec'">
            <spec v-model="form.specId"  ></spec>
        </bi-form-item>
        <bi-form-item label="变量名"  v-if="form.selectType=='variable'">
            <bi-input v-model="form.variableName"  ></bi-input>
        </bi-form-item>
        <bi-form-item label="数量"  v-if="form.selectType!='goods' && form.selectType!='variable'" >
            <bi-input v-model="form.number"  type="int" ></bi-input>
        </bi-form-item>
        <bi-form-item label="排序"  v-if="form.selectType!='goods' && form.selectType!='like' && form.selectType!='variable'" >
            <bi-select v-model="form.order" :clear="false"  >
                <bi-select-option value="newDesc" label="从新到旧"></bi-select-option>
                <bi-select-option value="newAsc" label="从旧到新"></bi-select-option>
                <bi-select-option value="saleDesc" label="销量由高到低"></bi-select-option>
                <bi-select-option value="saleAsc" label="销量由低到高"></bi-select-option>
                <bi-select-option value="priceDesc" label="价格由高到低"></bi-select-option>
                <bi-select-option value="priceAsc" label="价格由低到高"></bi-select-option>
            </bi-select>
        </bi-form-item>
    </div>
</template>

<script>
import fieldMixin from  '@@/admin/assets/bi-plug/fieldMixin.js';

import cate from '../../field/cate.vue';
import goods from '../../field/goods-list.vue';
import spec from '../../field/spec.vue';
import tag from '../../field/goods-tag.vue';
export default {
    mixins:[fieldMixin],
    components:{
        cate,
        goods,
        spec,
        tag
    },
    props:{
        rowShow:{
            type:Boolean,
            default:false
        }
    },
    methods:{
        
    },
    watch:{
        form:{
            handler(val){
                this.$emit('update:modelValue',val);
            },
            deep:true
        },
        modelValue(val){
            this.$assign(this.form,val);
        }
    },
    data(){
        let form = {
            selectType:'goods',
            cateId:'',
            goodsIds:'',
            brandId:'',
            tag:'',
            specId:'',
            variableName:'',
            number:''
        }
        this.$assign(form,this.modelValue);
        return {
            form
        }
    }
}
</script>